#ifndef _DATABASE_H__
#define _DATABASE_H__
#include <string>
#include <iostream>
#include <vector>
#include <mysql/mysql.h>
using CStrRef = const std::string &;
using StrMatrix = std::vector<std::vector<std::string>>;
class DataBase
{
public:
    // 连接
    virtual bool Connect(CStrRef host, CStrRef user, CStrRef passwd, CStrRef dbName, int port = 3306) = 0;

    // 执行sql语句
    virtual bool Exec(CStrRef sql) = 0;

    // 获取查询结果
    virtual StrMatrix GetSqlResult(CStrRef sql) = 0;

    // 事务
    virtual bool StartTransaction() = 0;
    // 提交
    virtual bool Commit() = 0;
    // 回滚
    virtual bool Rollback() = 0;

private:
    MYSQL mysql;
    bool isConnected;
};

#endif